package com.atguigu.multiReading;

import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.FutureTask;

public class CallableTest implements Callable {
    public static void main(String[] args) throws ExecutionException, InterruptedException {
        CallableTest callableTest=new CallableTest();
        FutureTask futureTask=new FutureTask(callableTest);
        Thread thread=new Thread(futureTask);
        thread.start();
        System.out.println(futureTask.get());
    }
    public Object call(){
        int sum=0;
        for(int i=1;i<=1000;i++){
            sum+=i;
        }
        return sum;
    }

}
